package com.luocj.refresh.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.luocj.refresh.R;
import com.luocj.refresh.model.MultiModel;

import java.util.List;

/**
 * Created by Administrator on 2018/2/9/009.
 */

public class MultiItemAdapter extends BaseMultiItemQuickAdapter<MultiModel, BaseViewHolder> {

    private Context mContext;
    private List<MultiModel> modelList;

    public MultiItemAdapter(Context context, List<MultiModel> data) {
        super(data);
        this.mContext = context;
        this.modelList = data;

        addItemType(MultiModel.TYPE_TEXT, R.layout.item_text);
        addItemType(MultiModel.TYPE_IMAGE, R.layout.item_image);
        addItemType(MultiModel.TYPE_TEXT_IMAGE, R.layout.item_text_image);
    }

    @Override
    protected void convert(BaseViewHolder holder, MultiModel item) {
        int itemViewType = holder.getItemViewType();
        switch (itemViewType) {
            case MultiModel.TYPE_TEXT:
                holder.setText(R.id.tv_content, item.getContent() + "type:" + item.getType());
                break;
            case MultiModel.TYPE_IMAGE:
                break;
            case MultiModel.TYPE_TEXT_IMAGE:
                holder.setText(R.id.tv_title, item.getContent() + "type :" + item.getType());
                break;
        }

    }
}
